package com.woniu.finance.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.woniu.finance.domain.ApartDepositReceivable;
import com.woniu.finance.service.IApartDepositReceivableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 应收押金Controller
 *
 * @author yy
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/finance/tbapartdepositreceivable")
@Api("应收押金管理")
public class ApartDepositReceivableController extends BaseController {
    @Autowired
    private IApartDepositReceivableService apartDepositReceivableService;

    /**
     * 查询应收押金列表
     */
    //@PreAuthorize("@ss.hasPermi('finance:tbapartdepositreceivable:list')")
    @GetMapping("/list")
    @ApiOperation("应收押金分页查询")
    public TableDataInfo list(ApartDepositReceivable apartDepositReceivable) {
        startPage();
        List<ApartDepositReceivable> list = apartDepositReceivableService.selectApartDepositReceivableList(apartDepositReceivable);
        return getDataTable(list);
    }

    /**
     * 导出应收押金列表
     */
    //@PreAuthorize("@ss.hasPermi('finance:tbapartdepositreceivable:export')")
    @Log(title = "应收押金", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("应收押金导出")
    public void export(HttpServletResponse response, ApartDepositReceivable apartDepositReceivable) {
        List<ApartDepositReceivable> list = apartDepositReceivableService.selectApartDepositReceivableList(apartDepositReceivable);
        ExcelUtil<ApartDepositReceivable> util = new ExcelUtil<ApartDepositReceivable>(ApartDepositReceivable.class);
        util.exportExcel(response, list, "应收押金数据");
    }

    /**
     * 获取应收押金详细信息
     */
    //@PreAuthorize("@ss.hasPermi('finance:tbapartdepositreceivable:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("根据主键查询应收押金")
    @ApiImplicitParam(name = "ids", value = "用户ID", required = true, dataType = "Long")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(apartDepositReceivableService.selectApartDepositReceivableById(id));
    }

    /**
     * 新增应收押金
     */
    //@PreAuthorize("@ss.hasPermi('finance:tbapartdepositreceivable:add')")
    @Log(title = "应收押金", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("添加应收押金")
    public AjaxResult add(@RequestBody ApartDepositReceivable apartDepositReceivable) {
        return toAjax(apartDepositReceivableService.insertApartDepositReceivable(apartDepositReceivable));
    }


   @RequestMapping("/feign/add")
    public Integer feignAddApartDepositReceivable(@RequestBody ApartDepositReceivable apartDepositReceivable) {
        return apartDepositReceivableService.insertApartDepositReceivable(apartDepositReceivable);
    }

    /**
     * 修改应收押金
     */
    //@PreAuthorize("@ss.hasPermi('finance:tbapartdepositreceivable:edit')")
    @Log(title = "应收押金", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("更新应收押金")
    public AjaxResult edit(@RequestBody ApartDepositReceivable apartDepositReceivable) {
        return toAjax(apartDepositReceivableService.updateApartDepositReceivable(apartDepositReceivable));
    }

    /**
     * 删除应收押金
     */
    //@PreAuthorize("@ss.hasPermi('finance:tbapartdepositreceivable:remove')")
    @Log(title = "应收押金", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除应收押金")
    @ApiImplicitParam(name = "ids", value = "主键数组", required = true, dataType = "Long")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(apartDepositReceivableService.deleteApartDepositReceivableByIds(ids));
    }
}
